package com.songlanyun.modules.order.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.songlanyun.common.drive.IBaseService;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.order.entity.Order;
import com.songlanyun.modules.order.model.dto.SubmitOrderDTO;
import com.songlanyun.modules.order.model.dto.UpdateOrderGoodsPriceDTO;
import com.songlanyun.modules.order.model.dto.UpdateOrderReceiptDTO;
import com.songlanyun.modules.order.model.vo.*;
import com.songlanyun.modules.ship.model.dto.BranchShipVO;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * 销售系统中的主订单
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2020-11-16 14:14:42
 */
public interface OrderService extends IBaseService<Long, Order> {

    PageUtils queryPage(Map<String, Object> params);

    List<Order> loadByPayOrderId(Long payOrderId);

    Order loadByShopIdAndId(Long shopId, Long orderId, boolean tw);
    Order loadById(Long orderId, boolean tw);


    Order loadByShopIdAndOrderNo(Long shopId, String orderNo, boolean tw);

    Order loadByOrderNo(String orderNo,boolean tw);

    Order loadByUserIdAndId(Long userId, Long orderId, boolean tw);

    PageUtils userOrdersPage(Long userId, Map<String, Object> params);

    PageUtils shopOrderPage(Map<String, Object> params);

    PageUtils areaOrdersPage(Map<String, Object> params);

    PageUtils allOrderPage(Map<String, Object> params);

    Order loadByShopKey(Long shopId, Long orderId);

    Order loadByUserKey(Long userId, Long orderId);

    Order refundOperate(Order order);

    List<Order> loadNeedAutoStockUp();

    /**
     * 快递查询
     *
     * @param orderNo
     * @return
     */
    String queryExpressExpNo(String orderNo, String mobile);

    Integer getCountCommonOrder(Long shopId, Long userId);

    UserOrderSlimStatisticsVo loadUserOrderSlimStatistics(Long shopId, Long userId);

    void updateGoodsPrice(Long shopId, UpdateOrderGoodsPriceDTO dto, Function<Object, Object> callBack);

    List<OrderVO> exportList(Map<String, Object> params);

    List<BranchShipVO> exportWaitShip(Map<String, Object> params);

    PageUtils shopServiceOrderPage(Map<String, Object> params);

    void userOrderReceipt(Long userId, UpdateOrderReceiptDTO dto);

    UserOrderNumStatisticsVo loadGeneralOrderStatistics(long userId);
    UserOrderNumStatisticsVo loadServiceOrderStatistics(long userId);
    UserOrderNumStatisticsVo loadApplyOrderStatistics(long userId);

    BigDecimal loadEquityStatistics(Long userId);

    BigDecimal loadPlatformMonthEquity();

    BigDecimal loadActivatingOrderCount(List<Long> userIds);

    R houniaoTest();

    BigDecimal getCountTotalAmount(LocalDate firstDayOfLastMonth, LocalDate lastDayOfLastMonth);

    void writeOff(Long userId, String orderCode);
}

